<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="/dk/Public/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="/dk/Public/css/bootstrap.min.css" />
        <link rel="stylesheet" href="/dk/Public/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="/dk/Public/css/dashboard.css" />
        <link rel="stylesheet" href="/dk/Public/css/bootstrap-switch.css" />
        <link rel="stylesheet" href="/dk/Public/css/icheck/all.css" />
    </head>

    <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#"><img src="/dk/Public/images/logo.png"/></a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><span>欢迎您：<?php echo ($_SESSION['userInfo']['real_name']); ?></span></li>
                
                <li><a href="<?php echo U('Admin/Auth/initAuth');?>">更新缓存</a></li>
                <li class="icon3"><a href="javascript:void(0);" onclick="common.modifyPwd('<?php echo U('Admin/User/modifyPwd');?>')">修改密码</a></li>
                <li class="icon2"><a href="<?php echo U('Admin/Login/login');?>">退出系统</a></li>
            </ul>
        </div>
    </div>
</nav>

<script type="text/javascript">
    var webRoot = "/dk";
</script>

    <div class="container-fluid">
        <div class="row">
            <link href="/dk/Public/css/font-awesome.min.css" rel="stylesheet">
<link href="/dk/Public/css/leftMenu.css" rel="stylesheet">
<div class="col-sm-3 col-md-2 sidebar">


    <ul id="accordion" class="accordion">
        <?php if(is_array($menuList)): $i = 0; $__LIST__ = $menuList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li thisC="<?php echo ($vo["controller"]); ?>">
            <?php if(empty($vo['subMenu'])): ?><div class="link" onclick="javascript:window.location.href = '<?php echo U($vo[url]);?>';" style="background-image: url('/dk/Public/images/icon/<?php echo ($vo["icon"]); ?>');"><?php echo ($vo["menuName"]); ?><i class="fa fa-chevron-down"></i></div>
                <?php else: ?>
                <div class="link" style="background-image: url('/dk/Public/images/icon/<?php echo ($vo["icon"]); ?>');"><?php echo ($vo["menuName"]); ?><i class="fa fa-chevron-down"></i></div>
                <ul class="submenu">
                        <?php if(is_array($vo['subMenu'])): $i = 0; $__LIST__ = $vo['subMenu'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><li thisCF="<?php echo ($vo["controller"]); ?>_<?php echo ($v["function"]); ?>"><a href="<?php echo U($v['url']);?>"><?php echo ($v["menuName"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
                </ul><?php endif; ?>
                
            </li><?php endforeach; endif; else: echo "" ;endif; ?>
		
	</ul>
</div>
<script>

    var controllerName = "<?php echo ($controllerName); ?>";
    var actionName = "<?php echo ($actionName); ?>";
    
</script>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
                    <div class="title">用户列表</div>
                    <div class="btn-group"><button type="button" id="addUser"  class="btn">添加用户</button></div>
                </div>
                
                <form class="jc-search form-inline searchForm" action="<?php echo U('Admin/User/index');?>" method="post">
                    <?php if($_SESSION['default_module']== 'Space'): ?><div class="form-group">
                            <label>所属团队:</label>
                            <select class="form-control" name="team_id" >
                                <option value="">全部</option>
                                <?php if(is_array($teamList)): $i = 0; $__LIST__ = $teamList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$team): $mod = ($i % 2 );++$i;?><option <?php if($team_id == $team['id']): ?>selected="selected"<?php endif; ?> value="<?php echo ($team["id"]); ?>"><?php echo ($team["team_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div><?php endif; ?>
                    <div class="form-group">
                        <label>用户组:</label>
                        <select class="form-control" name="role_id" >
                            <option value="">全部</option>
                            <?php if(is_array($roleList)): $i = 0; $__LIST__ = $roleList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$role): $mod = ($i % 2 );++$i;?><option <?php if($role_id == $role['id']): ?>selected="selected"<?php endif; ?> value="<?php echo ($role["id"]); ?>"><?php echo ($role["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>真实姓名:</label>
                        <input type="text" class="form-control" name="real_name" value="<?php echo ($real_name); ?>" placeholder="输入真实姓名">
                    </div>
                    <div class="form-group">
                       <label>手机号:</label>
                        <input type="text" class="form-control" name="mobile" value="<?php echo ($mobile); ?>" placeholder="输入手机号">
                    </div>
                    <div class="form-group">
                        <label>状态:</label>
                        <select class="form-control" name="status" >
                            <option value="-1">全部</option>
                            <option <?php if($status == '1'): ?>selected="selected"<?php endif; ?> value="1">启用</option>
                            <option <?php if($status == '0'): ?>selected="selected"<?php endif; ?> value="0">禁用</option>
                        </select>
                    </div>

                    <input class="btn" type="submit" value="搜索" />
                </form>
                
                <div class="table-responsive">
                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>用户名</th>
                                <th>登录账号</th>
                                <th>手机号</th>
                                <?php if($_SESSION['default_module']== 'Space'): ?><th>所属团队</th><?php endif; ?>
                                <th>角色</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php if(is_array($data['list'])): $i = 0; $__LIST__ = $data['list'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$user): $mod = ($i % 2 );++$i;?><tr>
                                <td><?php echo ($user["id"]); ?></td>
                                <td><?php echo ($user["real_name"]); ?></td>
                                <td><?php echo ($user["user_name"]); ?></td>
                                <td><?php echo ($user["mobile"]); ?></td>
                                <?php if($_SESSION['default_module']== 'Space'): ?><td><?php echo ((isset($user["team"]["team_name"]) && ($user["team"]["team_name"] !== ""))?($user["team"]["team_name"]):"-"); ?></td><?php endif; ?>
                                <td><?php echo ((isset($user["role"]["name"]) && ($user["role"]["name"] !== ""))?($user["role"]["name"]):"-"); ?></td>
                                <td>
                                    <?php if($user["status"] == 1): ?><span class="label label-success">启用</span>
                                    <?php else: ?>
                                        <span class="label label-danger">禁用</span><?php endif; ?>
                                </td>
                                <td><?php echo (date('Y-m-d H:i:s',$user["create_time"])); ?></td>
                                <td>
                                    <?php if($user['role']['super'] == 0): ?><a href="javascript:void(0)" userId="<?php echo ($user["id"]); ?>" class="editUser">修改</a> |
                                        <a href="javascript:void(0)" userId="<?php echo ($user["id"]); ?>" class="resetPass">重置密码</a> |
                                        <?php if($user['status'] == 1): ?><a href="javascript:void(0)" userId="<?php echo ($user["id"]); ?>" class="deUser">禁用</a>
                                        <?php else: ?>
                                            <a href="javascript:void(0)" userId="<?php echo ($user["id"]); ?>" class="enUser">启用</a><?php endif; endif; ?>
                            </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>    
                        </tbody>
                    </table>
                    <div class="page">
                    	<?php echo ($data["page"]); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
<style type="text/css">
    @-moz-keyframes circles-loader {
        0% {
            -moz-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -moz-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    @-webkit-keyframes circles-loader {
        0% {
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    @keyframes circles-loader {
        0% {
            -moz-transform: rotate(0deg);
            -ms-transform: rotate(0deg);
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -moz-transform: rotate(360deg);
            -ms-transform: rotate(360deg);
            -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    .circles-loader {
        position: absolute;
        top: 15px;
        left: 15px;
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        font-size: 28px;
        -moz-animation: circles-loader 1s infinite linear;
        -webkit-animation: circles-loader 1s infinite linear;
        animation: circles-loader 1s infinite linear;

    }

    .card {
        position: relative;
        text-align: center;
        vertical-align: middle;
        width: 60px;
        height: 60px;
        margin: 0 auto;
    }
</style>
<!--  动态弹窗统一配置  -->    
<div class="modal fade" id="commonModal">
</div>
<!--       END         -->
<!--  ALERT  --> 

<div class="modal fade" id="alertModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="alertModalBtn" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<!--     ALERT   END        --> 

<!--  confirm CONFIRM  --> 

<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" id="confirmModalCancel" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="confirmModalBtn" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>

<!--  CONFIRM end --> 

<!-- LOADING -->
<div class="modal fade" id="loadModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <div class="loading-title" style="text-align:center; font-size: 14px; font-weight: 700;"><p>内容加载中...请稍后...</p></div>

                <div class="card">
                    <span class="circles-loader glyphicon glyphicon-asterisk"></span>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- LOADING END -->
    <script type="text/javascript" src="/dk/Public/js/jquery.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/bootstrap-switch.js"></script>
    <script type="text/javascript" src="/dk/Public/js/icheck.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/common.js"></script>
    <script type="text/javascript" src="/dk/Public/js/validator.min.js"></script>
    <script>

        
        $("#tableData .editUser").click(function () {
            var userId = $(this).attr("userId");
            //console.log(userId);
            common.htmlAjax("<?php echo U('Admin/User/editUser');?>", {userId: userId}, function (html) {
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            })
        })

        $("#addUser").click(function () {
            common.htmlAjax("<?php echo U('Admin/User/addUser');?>", {}, function (html) {
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            })
        })
        
        $("#tableData .resetPass").click(function () {
            var userId = $(this).attr("userId");
            common.confirm("提示", "确定重置用户密码?", function () {
                common.ajax("<?php echo U('Admin/User/resetUserPass');?>", {userId: userId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "重置用户密码成功,密码已经改为123456!", function () {
                        common.reload();
                    });
                });
            });
        });

        $("#tableData .deUser").click(function () {
            var userId = $(this).attr("userId");
            common.confirm("提示", "确定禁用用户?", function () {
                common.ajax("<?php echo U('Admin/User/deUser');?>", {userId: userId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "用户禁用成功!", function () {
                        common.reload();
                    });
                });
            });
        });

        $("#tableData .enUser").click(function () {
            var userId = $(this).attr("userId");
            common.confirm("提示", "确定启用用户?", function () {
                common.ajax("<?php echo U('Admin/User/enUser');?>", {userId: userId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "用户启用成功!", function () {
                        common.reload();
                    });
                });
            });
        });
    </script>
</body>
</html>